package org.sibutu.plugin.struts2.jcr.wrapper;

import javax.jcr.*;
import javax.jcr.Node;
import java.io.InputStream;
import java.util.Calendar;

/**
 * Returned from NodeWrapper in case node.getProperty==null to avoid NullPointerException and to simplify development
 */
public class PropertyNullWrapperImpl extends PropertyWrapperImpl{
  private Node parent;
  private String name;

  public PropertyNullWrapperImpl(Node parent,String name,WrapperFactory wrapperFactory) {
    super(null,wrapperFactory);
    this.parent = parent;
    this.name = name;
  }

  public Value getValue() throws RepositoryException {
    return null;
  }

  public Value[] getValues() throws RepositoryException {
    return null;
  }

  public String getString() throws RepositoryException {
    return null;
  }

  public InputStream getStream() throws RepositoryException {
    return null;
  }

  public long getLong() throws RepositoryException {
    return 0;
  }

  public double getDouble() throws RepositoryException {
    return 0;
  }

  public Calendar getDate() throws RepositoryException {
    return null;
  }

  public boolean getBoolean() throws RepositoryException {
    return false;
  }

  public Node getNode() throws  RepositoryException {
    return null;
  }

  public int getType() throws RepositoryException {
    return PropertyType.UNDEFINED;
  }

  public String getPath() throws RepositoryException {
    return parent.getPath()+"/"+name;
  }

  public String getName() throws RepositoryException {
    return name;
  }

  public Node getParent() throws RepositoryException {
    return parent;
  }

  public Session getSession() throws RepositoryException {
    return parent.getSession();
  }
}